cmake_minimum_required(VERSION 3.12.4)

project(vulnerability_scanner_unit_tests)

set(CMAKE_CXX_FLAGS_DEBUG "-g --coverage -fsanitize=address,leak,undefined")

include_directories(${SRC_FOLDER}/external/flatbuffers/include/)

file(GLOB PROJECT_SOURCES
    *.cpp
    ${SRC_FOLDER}/vulnerability_scanner/src/*[!main]*.cpp
    ${SRC_FOLDER}/vulnerability_scanner/src/databaseFeedManager/*.cpp
    ${SRC_FOLDER}/vulnerability_scanner/src/policyManager/*.cpp
    ${SRC_FOLDER}/vulnerability_scanner/src/scanOrchestrator/*.cpp
    ${SRC_FOLDER}/vulnerability_scanner/src/scanOrchestrator/versionMatcher/*.cpp
)

link_directories(${SRC_FOLDER}/external/rocksdb/build)
link_directories(${SRC_FOLDER}/external/flatbuffers/build/)
link_directories(${SRC_FOLDER}/external/curl/lib/.libs/)

add_executable(${PROJECT_NAME} ${PROJECT_SOURCES})

target_link_libraries(${PROJECT_NAME}
    debug gtestd
    debug gmockd
    debug gtest_maind
    debug gmock_maind
    optimized gtest
    optimized gmock
    optimized gtest_main
    optimized gmock_main
    flatbuffers
    rocksdb
    router
    urlrequest
    curl
    pthread
)

target_link_libraries(${PROJECT_NAME} vulnerability_scanner)

target_compile_definitions(${PROJECT_NAME} PUBLIC FLATBUFFER_SCHEMAS_DIR="${SRC_FOLDER}/wazuh_modules/vulnerability_scanner/schemas/")

add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})
